<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Evolving Curves</title>
  <link rel="stylesheet" href="http://playinggod.150m.com/layout.css" />
</head>
<body>

<div id="Content">
<h1>Evolving Curves</h1>
<p>The technique of evolution applies to all sorts of things. Its
greatest strength is that it is so general. It can create anything
from electrical audio filtering circuits to curved mirrors to
dolphins. In this article, we get to watch curves evolve. While curves
are far from anything biological, they too can evolve.</p>

<p>Evolution is very good at adapting things to their
environments. People evolved to be good at dissipating heat, because
we had to do quite a bit of running around in hot weather. Burrowing
rodents are well adapted to digging. Birds have beaks adapted to their
food, because beaks that are good at eating seeds won't be so good for
eating fish. There are countless examples. This sort of thing would
seem to imply an intelligent designer with a plan for every
species. Unfortunately for those who like the idea of such a grand
plan, it doesn't.</p>

<h2>The experiment</h2>
<p>Suppose that we want to evolve a curve. Specifically, let's see if
we can evolve a curve that looks like this one:</p>

<div align="center"><img src="target.png" alt="Target curve" /></div>

<p>We have a big problem right off the bat here: how do we represent
our curves? With living organisms, we have DNA (and sometimes
RNA). What equivalent can we use with curves?</p>

<p>Fortunately, math has the answer. I won't go into the details of
how it works here (if you want a more detailed explanation, see <a
href="curvefit-explanation.html">this page</a>, but suffice it to say
that we can take a sequence of numbers, like "1.0, -1.5, 1.24, -3.6,
-4.2, 1.8, -2.7, 5.6", and turn that into a curve.</p>

<p>Suppose that we start with a bunch of these number sequences (I'll
call them genomes even though they don't use DNA) and set evolution to
work on them? Do what we did in the <a href="phrase.html">Evolving a
phrase</a> example: pick the best curve in each generation and fill up
the next generation with its mutated children. The best curve in each
generation is the one that looks most like the target curve shown
above.</p>

<p>Let's get started, then! After just a few generations, we have this
curve. The target curve is in red, and the approximation we evolved is
in green:</p>

<div align="center"><img src="1.png" alt="First lousy approximation" /></div>

<p>That doesn't look close at all, does it? The thing is, it's better
than everything that came before it. The first curve was just a
straight line, and it was a bit below where the slightly curved green
line is now. Evolution doesn't care about how absolutely fit organisms
are; it just cares about how good organisms are <i>relative to other
organisms</i>. That's why we have such annoying, apparently worthless
creatures as lice and tapeworms. Parasites feed on other creatures, so
they can survive. Our own feelings about them doesn't come into the
picture.</p>

<p>Let's evolve the thing a little more and see what happens.</p>

<div align="center"><img src="2.png" alt="Getting better" /></div>

<p>The curve that we're evolving is now getting visibly better. It
curves in a way that sort of resembles the target, and it's going up,
getting nearer to the target. This sort of mimicry is a lot like what
happens in nature with camoflage and mimicry. Look at this insect:</p>

<div align="center"><img src="Droneflybeemimic.jpg" alt="Dronefly: looks like a bee but
isn't one" /></div>

<p>That isn't a honeybee. It's a dronefly, which just <i>looks</i>
like a honeybee. If you look closely at it, you can clearly see that
it isn't a honeybee, but if it was flying around a few meters from
you, chances are you wouldn't bother to look that closely. You would
just think, "Bee! Bees have stingers!" and avoid it. That's exactly
what you're supposed to do. The dronefly evolved to look like a bee so
that animals wouldn't bother it.</p>

<p>Of course, an animal might realize that the dronefly has
differently shaped eyes, a wide waist, and only two wings, and decide
to bother it. But some portion of the time thay will <i>not</i>
realize this, and marginal protection is a lot better than no
protection. The droneflies didn't just hold a meeting and decide to
look like honeybees. They just evolved to look more and more like
honeybees, since the closer they got to looking like honeybees, the
more likely they were to live long enough to pass on their genes to
the next generation.</p>

<p>As the generations go on, mimics get better at mimicry. That's sure
happening with our curves; let's look at what some more generations
can do:</p>

<div align="center"><img src="3.png" alt="Quite nice approximation" /></div>

<p>That's looking pretty good. Our approximation is really
improving. It still isn't perfect, but it's very close. We can even
improve it further, if we want to:</p>

<div align="center"><img src="4.png" alt="The pinnacle of evolution" /></div>

<p>This curve looks <i>really</i> close. The genome is "1.7417493,
-3.0388288, -0.7252705, -1.5580888, -2.878299, 1.1152457, -2.9188838,
5.636423". It's so near perfect that you could almost swear that
someone must have intervened in the process somewhere to guide it to
its current state of glorious near-perfection. The thing is, I didn't
intervene. I didn't do anything except set things up to evolve and
then sit back and watch evolution happen. It happened.</p>

<p>In fact, I don't think I <i>could</i> have intervened, even if I
wanted do. Look at those numbers. They're meaningless to mere
humans. How could I possibly know that 1.7417493 would have made a
good first number? How could I have guided this when I could never
wrap my mind around it? It's just too big for me to understand. It
would take a mind of incalculable intelligence to design that
curve---or evolution. Here I used evolution, and it worked.</p>

<h2>Genetic engineering</h2>
<p>Of course, sometimes you do want to intervene. That's what genetic
engineering is all about: imposing our will on nature. That may sound
bad, but that's what we've been doing ever since we domesticated
plants for food.</p>

<p>Unfortunately, our minds don't have the capacity to grasp the
complexity of nature, and any abrupt modifications we make are going
to be just crude slicing and splicing. We make a great effort to
understand what we're doing, employing some of our brightest people
and most powerful computers. But think: do you really want to
understand the mind-boggling complexity of <a
href="http://www.genome.jp/dbget-bin/show_pathway?hsa00561+43">Glycerolipid
metabolism</a>? Do you know where acetylcholinesterase comes into play
in the process? Even if you figure that out, could you possibly
understand all the millions of things that interact with each other in
a mind-boggling number of ways in any organism?</p>

<p>Imagine what would happen if we transplanted some silk-related
genes from spiders into goats. This isn't idle speculation; Nexia
Biotechnologies actually did this, and they're using proteins from the
goats' milk to make very strong fibers. What would the goats be like?
Would they have eight legs, or something?</p>

<p>No. They're normal goats, except that their milk contains spider
silk protein. Adding genes from something does not necessarily make
the organism that gets the gene transplant more like the animal it got
the genes from. To illustrate this, let's try a little genetic
engineering ourselves.</p>

<p>Perhaps we could produce a better approximation if we cheated and
gave our approximation a gene transplant from the target curve. Let's
try it. The second number in the target genome is -1.5, and our best
approximation has -3.0388288 in that place. What would happen if we
changed -3.0388288 to -1.5 in our approximation? Would we get a better
approximation? Let's find out:</p>

<div align="center"><img src="4altered.png" alt="An evil genetically
engineered monstrosity" /></div>

<p>Actually, that genetically engineered monstrosity is worse than our
evolved curve, despite the fact that it's genetically closer to the
target curve. What goes on?</p>

<p>There are other genetic differences. The evolved approximation
looks like the target curve, but it's really not all that
similar. They use different ways to achieve the same results, like
sharks and dolphins, or bats and birds. This is called "convergent
evolution".</p>

<p>What happens if we put our genetically engineered curve back into
the gene pool and evolve it? It changes beyond recognition, into
something with numbers that are clearly different from anything we've
seen so far: "1.9564426, -2.509609, -0.6418174, -2.1601012, -3.174109,
1.278431, -2.837388, 5.6281333". Has evolution gone and mucked
everything up? Let's look at the graph to find out:</p>

<div align="center"><img src="alternate.png" alt="A different curve" /></div>

<p>That doesn't look much different. Actually, it's the best
approximation yet; it stays near the target curve everywhere, and fits
very tightly. But it's just a jumble of numbers!</p>

<p>That's the miracle of evolution: that, with random mutation and
some kind of selection, natural or otherwise, we can accomplish feats
beyond the capacity of any human. Sure, it sounds implausible, but
look at the results.</p>

<hr />

<p style="font-size: small;">Because I'm so conscientous, for those so
inclined I will provide the source code of the program I used to do
this experiment. You will need an implementation of the Common Lisp
programming language, such as <a
href="http://www.lispworks.com/downloads/lw-personal-edition.html">Xanalys
Lispworks</a>. The file is <a
href="curvefit.lisp">curvefit.lisp</a>.</p>

<p style="font-size: small;">The dronefly picture is from
<a href="http://wikipedia.org/">Wikipedia</a>, used by permission.</p>
</div>

<div id="Menu">
<a href="/">Main page</a><br />
<a href="/phrase.html">Evolving a Phrase</a><br />

<a href="/tierra/index.html">Tierra: a fancy simulation</a>
<a href="http://www.creationtheory.org/">Creationtheory.org</a>
</div>

</body>
</html>